package com.dyb.demo.java8;

import com.dyb.demo.util.PrintUtils;

/**
 * 接口创建匿名实现类
 * @author dyb
 * @date 2020/7/18
 */
public class LamdaDemo {

    public static void main(String[] args) {

        LamdaDemo demo = new LamdaDemo();
        demo.test();


    }

    void test () {
        Meat meat = (() -> PrintUtils.printWithThreadName("接口匿名内部类"));
        meat.eat();

        ThreadFactory threadFactory = (r -> new Thread(r, "thread"));
        threadFactory.newThread(() -> PrintUtils.printWithThreadName("创建线程")).start();
    }

    interface Meat {
        void eat();
    }

    interface ThreadFactory {

        Thread newThread(Runnable r);
    }
}
